#!/bin/sh

export PATH=.:$PATH

TARGET="$1"
shift

if [ "$TARGET" = "emacs" ]; then
    exec emacs -nw -q --eval "(progn (add-to-list 'load-path \"elisp\")(find-file-noselect \"elisp/remacs.el\" t)(eval-buffer (get-buffer \"remacs.el\"))(remacs-test))" $*
elif [ "$TARGET" = "sslserver" ]; then
    rm -f client.log ~/server.log sslclient.log sslserver.log
    ./remacs -sS -c tests/certs/server1.pem -C tests/certs/cacert1.pem -i server1 $*
elif [ "$TARGET" = "sslclient" ]; then
    ./remacs -S -c tests/certs/client1.pem -C tests/certs/cacert1.pem -i client1 localhost $*
elif [ "$TARGET" = "client" ]; then
    ./remacs -i client1 localhost $*
else
    echo "Usage: $0 [emacs|sslserver|sslclient|client]"
fi
